<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
--><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>Cordova API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
</head>
<body>
        <div id="header">
            <h1><a href="index.html"><strong>Cordova</strong> Documentation</a></h1>
            <small>
                <select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="1.7.0rc1">1.7.0rc1</option>
<option selected value="1.7.0">1.7.0</option>
<option value="1.6.1">1.6.1</option>
<option value="1.6.0rc1">1.6.0rc1</option>
<option value="1.6.0">1.6.0</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value="0.9.5.1">0.9.5.1</option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
</optgroup>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
</optgroup>
<optgroup label="Japanese" value="jp"><option value="0.9.5">0.9.5</option></optgroup></select></small>
        </div>
        <div id="subheader">
            <h1>Getting Started with Android</h1>
            <small><select><option value="Getting%2520Started%2520with%2520Android">Getting Started with Android</option>
<option value="Getting%20Started%20with%20Android_1_requirements">      - 1. Requirements</option>
<option value="Getting%20Started%20with%20Android_2_install_sdk_cordova">      - 2. Install SDK + Cordova</option>
<option value="Getting%20Started%20with%20Android_3_setup_new_project">      -  3. Setup New Project</option>
<option value="Getting%20Started%20with%20Android_4_hello_world">      - 4. Hello World</option>
<option value="Getting%20Started%20with%20Android_5a_deploy_to_simulator">      - 5A. Deploy to Simulator</option>
<option value="Getting%20Started%20with%20Android_5b_deploy_to_device">      - 5B. Deploy to Device
</option>
<option value="Getting%20Started%20with%20Android_done">      - Done!</option></select></small>
        </div>

        <div id="sidebar">
            <div class="vertical_divider"></div>
        <h1>API Reference</h1>
<ul>
<li><a href="cordova_accelerometer_accelerometer.md.html#Accelerometer">Accelerometer</a></li>
<li><a href="cordova_camera_camera.md.html#Camera">Camera</a></li>
<li><a href="cordova_media_capture_capture.md.html#Capture">Capture</a></li>
<li><a href="cordova_compass_compass.md.html#Compass">Compass</a></li>
<li><a href="cordova_connection_connection.md.html#Connection">Connection</a></li>
<li><a href="cordova_contacts_contacts.md.html#Contacts">Contacts</a></li>
<li><a href="cordova_device_device.md.html#Device">Device</a></li>
<li><a href="cordova_events_events.md.html#Events">Events</a></li>
<li><a href="cordova_file_file.md.html#File">File</a></li>
<li><a href="cordova_geolocation_geolocation.md.html#Geolocation">Geolocation</a></li>
<li><a href="cordova_media_media.md.html#Media">Media</a></li>
<li><a href="cordova_notification_notification.md.html#Notification">Notification</a></li>
<li><a href="cordova_storage_storage.md.html#Storage">Storage</a></li>
</ul>
<h1>Guides</h1>
<ul>
<li><a href="guide_getting-started_index.md.html#Getting%20Started%20Guides">Getting Started Guides</a></li>
<li><a href="_index.html">Keyword Index</a></li>
</ul>
</div>

        <div id="scrollable">
            <div id="content">
                <h1><a name="Getting%20Started%20with%20Android">Getting Started with Android</a></h1>

<p>This guide describes how to set up your development environment for Cordova and run a sample application.  Note that Cordova used to be called PhoneGap, so some of the sites still use the old PhoneGap name.</p>

<h2>
<a name="Getting%20Started%20with%20Android_1_requirements">1. Requirements</a>
</h2>

<ul>
<li>Eclipse 3.4+</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_2_install_sdk_cordova">2. Install SDK + Cordova</a>
</h2>

<ul>
<li>Download and install <a class="external" href="http://www.eclipse.org/downloads/">Eclipse Classic</a>
</li>
<li>Download and install <a class="external" href="http://developer.android.com/sdk/index.html">Android SDK</a>
</li>
<li>Download and install <a class="external" href="http://developer.android.com/sdk/eclipse-adt.html#installing">ADT Plugin</a>
</li>
<li>Download the latest copy of <a class="external" href="http://phonegap.com/download">Cordova</a> and extract its contents. We will be working with the Android directory.</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_3_setup_new_project"> 3. Setup New Project</a>
</h2>

<ul>
<li>
<p>Launch Eclipse, and select menu item <strong>New &gt; Android Project</strong>.  Fill out the three panels of the <strong>New Android Project</strong> wizard shown below.</p>

<p><img src="img/guide/getting-started/android/AndroidFlow.png" alt="" title=""></p>
</li>
<li>
<p>In the root directory of your project, create two new directories:</p>

<ul>
<li><strong>/libs</strong></li>
<li><strong>assets/www</strong></li>
</ul>
</li>
<li>Copy <strong>cordova-1.7.0.js</strong> from your Cordova download earlier to <strong>assets/www</strong>
</li>
<li>Copy <strong>cordova-1.7.0.jar</strong> from your Cordova download earlier to <strong>/libs</strong>
</li>
<li><p>Copy <strong>xml</strong> folder from your Cordova download earlier to <strong>/res</strong></p></li>
<li>
<p>Verify that <strong>cordova-1.7.0.jar</strong> is listed in the Build Path for your project. Right click on the /libs folder and go to <strong>Build Paths/ &gt; Configure Build Path...</strong>. Then, in the Libraries tab, add <strong>cordova-1.7.0.jar</strong> to the project. If Eclipse is being temperamental, you might need to refresh (F5) the project once again.</p>

<p><img src="img/guide/getting-started/android/buildPath.jpg" alt="" title=""></p>
</li>
<li>
<p>Edit your project's main Java file found in the <strong>src</strong> folder in Eclipse:</p>

<ul>
<li>Add <strong>import org.apache.cordova.*;</strong>
</li>
<li>Change the class's extend from <strong>Activity</strong> to <strong>DroidGap</strong>
</li>
<li>Replace the <strong>setContentView()</strong> line with <strong>super.loadUrl("file:///android_asset/www/index.html");</strong> </li>
</ul>
<p><img src="img/guide/getting-started/android/javaSrc.jpg" alt="" title=""></p>
</li>
<li><p>Right click on AndroidManifest.xml and select <strong>Open With &gt; XML Editor</strong></p></li>
<li>
<p>Paste the following permissions between the <strong>&lt;uses-sdk.../&gt;</strong> and <strong>&lt;application.../&gt;</strong> tags.</p>

<p></p>
<pre class="prettyprint"><code>&lt;supports-screens 
    android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:resizeable="true" 
    android:anyDensity="true" /&gt;
&lt;uses-permission android:name="android.permission.CAMERA" /&gt;
&lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
&lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
&lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
&lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
&lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
&lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
&lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt;
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; 
&lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
&lt;uses-permission android:name="android.permission.BROADCAST_STICKY" /&gt;
</code></pre>
</li>
<li>
<p>Support orientation changes by pasting the folowing inside the <strong>&lt;activity&gt;</strong> tag.</p>

<p></p>
<pre class="prettyprint"><code>android:configChanges="orientation|keyboardHidden"
</code></pre>
</li>
<li>
<p>Your AndroidManifest.xml file should look like</p>

<p></p>
<p><img src="img/guide/getting-started/android/manifest.jpg" alt="" title=""></p>
</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_4_hello_world">4. Hello World</a>
</h2>

<ul>
<li>
<p>Create and open a new file named <strong>index.html</strong> in the <strong>assets/www</strong> directory. Paste the following code:</p>

<pre class="prettyprint"><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Cordova&lt;/title&gt;
&lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Hello World&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_5a_deploy_to_simulator">5A. Deploy to Simulator</a>
</h2>

<ul>
<li>Right click the project and go to <strong>Run As &gt; Android Application</strong>
</li>
<li>Eclipse will ask you to select an appropriate AVD. If there isn't one, then you'll need to create it.</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_5b_deploy_to_device">5B. Deploy to Device
</a>
</h2>

<ul>
<li>Make sure USB debugging is enabled on your device and plug it into your system. (<strong>Settings &gt; Applications &gt; Development</strong>)</li>
<li>Right click the project and go to <strong>Run As &gt; Android Application</strong>
</li>
</ul>
<h2>
<a name="Getting%20Started%20with%20Android_done">Done!</a>
</h2>

            </div>
        </div>

        <!-- Functionality and Syntax Highlighting -->
        <script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
</body>
</html>
